//
// StreamParameters.cpp for StreamParameters in /home/mambou_j//babel-2014/babel-2014/Portaudio
// 
// Made by jacquesquentin mamboumouafo
// Login   <mambou_j@epitech.net>
// 
// Started on  Tue May 15 21:08:05 2012 jacquesquentin mamboumouafo
// Last update Tue May 15 22:14:33 2012 jacquesquentin mamboumouafo
//


#include	"StreamParameters.hpp"
#include	<cstddef>
#include	"Device.hpp"

namespace	portaudio
{

  StreamParameters::StreamParameters()
  {
  }

  StreamParameters::StreamParameters(const DirectionSpecificStreamParameters &inputParameters, const DirectionSpecificStreamParameters &outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags flags) : inputParameters_(inputParameters), outputParameters_(outputParameters), sampleRate_(sampleRate), framesPerBuffer_(FramesPerBuffer), flags_(flags)
  {
  }

  void	StreamParameters::setSampleRate(double sampleRate)
  {
    sampleRate_ = sampleRate;
  }

  void	StreamParameters::setFramesPerBuffer(unsigned long framesPerBuffer)
  {
    framesPerBuffer_ = framesPerBuffer;
  }

  void	StreamParameters::setFlag(PaStreamFlags flag)
  {
    flags_ |= flag;
  }

  void	StreamParameters::unsetFlag(PaStreamFlags flag)
  {
    flags_ &= ~flag;
  }

  void	StreamParmeters::clearFlags()
  {
    flags_ = paNoFlag;
  }

  void	StreamParameters::setInputParameters(const DirectionSpecificStreamParameters &parameters)
  {
    inputParameters_ = parameters;
  }

  void	StreamParameters::setOutputParameters(const DirectionSpecificStreamParameters &parameters)
  {
    outputParameters_ = parameters;
  }

  bool	StreamParameters::isSupported() const
  {
    return (pa_IsFormatSupproted(inputParameters_.paStreamParameters(), outputParameters_.paStreamParameters(), sampleRate_) == paFormatsSupported);
  }

  double	StreamParameters::sample() const
  {
    return sampleRate_;
  }

  unsigned	long	StreamParameters::framesPerBuffer() const
  {
    return framesPerBuffer_;
  }

  PaStreamFlags	StreamParameters::flags() const
  {
    return flags_;
  }

  bool	StreamParameters::isFlagSet(PaStreamFlags flag) const
  {
    return((flags_ & flag) != 0);
  }

  DirectionSpecificStreamParameters	&StreamParameters::inputParameters() const
  {
    return inputParameters_;
  }

  const	DirectionSpecificStreamParameters &SreamParameters::inputParameters() const
  {
    return inputParameters_;
  }

  DirectionSpecificStreamParameters	&StreamParameters::outputParameters()
  {
    return outputParameters_;
  }

  const	DirectionSpecificStreamParameters &StreamParameters::outputParameters() const
  {
    return outputParameters_;
  }
}
